<template>
  <div class="box">
    <!-- <div class="add" @click="add()">新增</div> -->
    <div>
      <van-search
        class="info_search input_text"
        v-model="value"
        @search="onSearch"
        @clear="clearSearch"
        placeholder="搜索"
      />
      <van-tabs>
        <van-tab title="检查报告">
          <van-list
            :finished="myFinished"
            v-model="myLoading"
            finished-text="没有更多了"
          >
            <van-cell class="card" v-for="(item, index) in myList" :key="index">
              <div>
                <div>
                  <div class="title">
                    <div>{{ item.TemplateName }}</div>
                  </div>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_contract_number.png"
                      />当前编号：{{ item.CurrentNum }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_date.png"
                      />年份：{{ item.Key }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_user.png"
                      />录入人：{{ item.CreateChName }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_date.png"
                      />录入时间：{{ item.CreateDate | formatDate }}
                    </van-col>
                  </van-row>
                  <van-divider />
                  <div class="op_btn">
                    <div class="btn_item" @click="edit(item.TemplateCode)">
                      <img
                        src="@/assets/Images/AppIcon/icon_list_edit.png"
                        alt=""
                      />
                      <div class="mr-10">编号设置</div>
                    </div>
                  </div>
                </div>
              </div>
            </van-cell>
          </van-list>
        </van-tab>
        <van-tab title="隐患报告"
          ><van-list
            :finished="myFinished2"
            v-model="myLoading2"
            finished-text="没有更多了"
          >
            <van-cell
              class="card"
              v-for="(item, index) in myList2"
              :key="index"
            >
              <div>
                <div>
                  <div class="title">
                    <div>{{ item.TemplateName }}</div>
                  </div>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_contract_number.png"
                      />当前编号：{{ item.CurrentNum }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_date.png"
                      />年份：{{ item.Key }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_user.png"
                      />录入人：{{ item.CreateChName }}
                    </van-col>
                  </van-row>
                  <van-row gutter="20">
                    <van-col>
                      <img
                        class="icon"
                        src="@/assets/Images/AppIcon/icon_list_date.png"
                      />录入时间：{{ item.CreateDate | formatDate }}
                    </van-col>
                  </van-row>
                  <van-divider />
                  <div class="op_btn">
                    <div class="btn_item" @click="edit(item.TemplateCode)">
                      <img
                        src="@/assets/Images/AppIcon/icon_list_edit.png"
                        alt=""
                      />
                      <div class="mr-10">编号设置</div>
                    </div>
                  </div>
                </div>
              </div>
            </van-cell>
          </van-list>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import { Toast, Form } from "vant";
import { qyReportTemplateList } from "@/api/qy";
var wait = 60;
export default {
  data() {
    return {
      value: "",
      myList: [],
      myList2: [],
      myFilter: {
        page: 0,
        dataType: "List",
        reportType: 1,
        jgType: "supervision",
      },
      myFilter2: {
        page: 0,
        dataType: "List",
        reportType: 2,
        jgType: "supervision",
      },
      loading: false,
      finished: false,
      myLoading: false,
      myFinished: false,
      myLoading2: false,
      myFinished2: false,
    };
  },
  created() {
    this.getMyList();
    this.getMyList2();
  },
  methods: {
    add() {
      this.$router.push({
        path: "/DangerReportNumSet/Detail",
        query: { id: 0 },
      });
    },
    onSearch() {
      var conditions1 = [];
      if (this.value) {
        conditions1.push({
          Name: "Keywords",
          DisplayName: this.value,
          Value: this.value,
          Operator: "like",
          DataType: "String",
        });
      }
      this.myFilter.page = 0;
      this.myFilter.conditions = JSON.stringify(conditions1);
      this.myFilter2.page = 0;
      this.myFilter2.conditions = JSON.stringify(conditions1);
      this.getMyList();
      this.getMyList2();
    },
    clearSearch() {
      this.myFilter = {
        page: 0,
        dataType: "List",
        reportType: 1,
        jgType: "supervision",
      };
      this.myFilter2 = {
        page: 0,
        dataType: "List",
        reportType: 2,
        jgType: "supervision",
      };
      this.value = "";
      this.getMyList();
      this.getMyList2();
    },
    getMyList() {
      this.myLoading = true;
      qyReportTemplateList(this.myFilter).then((res) => {
        this.myLoading = false;
        if (!res.data.HasNextPage) {
          this.myFinished = true;
        }
        this.myList = res.data.Data;
        this.myFilter.page = res.data.PageIndex;
      });
    },
    getMyList2() {
      this.myLoading = true;
      qyReportTemplateList(this.myFilter2).then((res) => {
        this.myLoading2 = false;
        if (!res.data.HasNextPage) {
          this.myFinished2 = true;
        }
        this.myList2 = res.data.Data;
        this.myFilter2.page = res.data.PageIndex;
      });
    },
    // 编号设置
    edit(templateCode) {
      if (templateCode) {
        this.editFlag = true;
      } else {
        this.editFlag = false;
      }
      this.$router.push({
        path: "/DangerReportNumSet/Detail",
        query: { templateCode: templateCode },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.register-form {
}
.phone {
  position: relative;
  .code {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 12px;
  }
}
.register-info {
  background-color: #e8f1f8;
  padding-bottom: 20px;
}
.img-box {
  height: 50px;
  width: 50px;
  padding: 10px;
  position: absolute;
  left: 50%;
  top: 60px;
  background-color: #fff;
  border-radius: 50%;
  overflow: hidden;
}
.popup-title {
  line-height: 35px;
  padding: 10px;
  font-size: 15px;
  padding-left: 20px;
}

.op_btn {
  display: flex;
  justify-content: flex-end;
  .btn_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>